<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/


// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
global $jbconfig, $option;
?>
<script language="javascript" type="text/javascript">
function updateCoupon(){
    var form = document.creditConfirm;
    
    if( form.coupon_code.value == "" ){
        alert("<?php echo JText::_("Coupon code is required");?>");
        return false;
    }
    form.task.value = "credit_confirm";
    
    form.submit();
}
</script>
<div id="jobboard-content">
<div class="moduletable clearfix">
		<h3>
			<span><?php echo JText::_("Credit order confirmation");?></span>
		</h3>
				
		<form id="creditConfirm" name="creditConfirm" action="<?php echo JURI::root();?>index.php" method="GET">
			<?php if($this->Itemid){
				echo "<input type='hidden' id='Itemid' name='Itemid' value='".$this->Itemid."' />";
			}
			?>

			<table class="tabledata credit-confirm">
		    	<tr class="first">
		    		<td class="key" width="20%">
						<?php echo JText::_( 'Title' ); ?>:
					</td>
					<td>
						<strong><?php echo $this->item->title; ?></strong>
					</td>
		    	</tr>	
		    
		    	<tr>
		    		<td class="key">
						<?php echo JText::_( 'Credit amount' ); ?>:
					</td>
					
					<td>
						<strong><?php echo $this->item->value; ?></strong>
					</td>				
		    	</tr>	    	
		         	
		    	<tr>
		    		<td class="key">
						<?php echo JText::_( 'Price' ); ?>:
					</td>
					<td>
						<strong><?php echo $this->item->price; ?></strong>
						(<?php echo $jbconfig['currency']->get('currency', '$');?>)
					</td>
		    	</tr>
		    	<?php
		    		// Check TAX
		    		if( $this->tax ){
		    			$this->item->price = $this->tax->price;
		    			?>
		    			<tr>
				    		<td class="key">
								<?php echo JText::_( 'TAX Rate' ); ?>:
							</td>
							<td>
								<?php echo $this->tax->tax_rate; ?>%
							</td>
				    	</tr>
				    	<tr>
				    		<td class="key">
								<?php echo JText::_( 'Price after TAX' ); ?>:
							</td>
							<td>
								<strong><?php echo $this->tax->price; ?></strong>
								(<?php echo $jbconfig['currency']->get('currency', '$');?>)
							</td>
				    	</tr>
		    			<?php
		    		}
		    	?>
		    	
		    	<?php if( isset($this->discountInfo) ){ 
		    	    // Show discount number in Credit confirm Form
		    	    $discountInfo = $this->discountInfo;
		    	?>
		    	<tr>
		    		<td class="key">
						<?php echo JText::_( 'Discount amount' ); ?>:
					</td>
					<td>
						<strong><?php echo $discountInfo->discount_amount; ?></strong>
						(<?php echo $jbconfig['currency']->get('currency', '$'); ?>)
					</td>
		    	</tr>
		    	<tr>
		    		<td class="key">
						<?php echo JText::_( 'Total Price after Discount' ); ?>:
					</td>
					<td>
						<strong><?php echo ( $this->item->price - $discountInfo->discount_amount ); ?></strong>
						(<?php echo $jbconfig['currency']->get('currency', '$');?>)
					</td>
					<input type="hidden" name="coupon_id" value="<?php echo $discountInfo->id;?>" />
		    	</tr>
		    	<?php } ?>
		    	
			   	<tr class="last">
					<td width="28%"><?php echo JText::_("Payment Method");?>: </td>
					<td width="72%">
						<?php if(isset($this->payment_method)){?>
							<b><?php echo $this->payment_method->alias; ?></b>
						<?php }else{?>
							<?php echo $this->paysys; ?>
						<?php }?>
					</td>
			  	</tr>
			  	
			  	<tr>
		    		<td class="key">
						<?php echo JText::_( 'Coupon code' ); ?>:
					</td>
					<td>
						<input type="text" name="coupon_code" size="20" value="<?php echo JRequest::getVar('coupon_code', ''); ?>">
						<input type="button" class="button" name="coupon" value="<?php echo JText::_('Update'); ?>" onclick="return updateCoupon();" />
					</td>
		    	</tr>
			  	 
			</table>
			<br />
			
			<input type="submit" class="button" name="Submit" value="<?php echo JText::_("CheckOut"); ?>" />
			<input type="button" class="button" name="cancel" value="<?php echo JText::_('Cancel'); ?>" onclick="document.location.href='<?php echo JRoute::_("index.php?option=com_jajobboard&view=japosts&layout=buycredit");?>';" />
			
			<input type="hidden"  name="option" value="<?php echo $option;?>" />
			<input type="hidden"  name="task" value="credit_checkout" />
			<input type="hidden"  name="layout" value="credit_confirm" />
			<input type="hidden"  name="view" value="japayment" />
			<input type="hidden"  name="cid" value="<?php echo $this->item->id; ?>" />
			<input type="hidden"  name="ppid" value="1<?php echo $this->item->id; ?>" />
			<input type="hidden"  name="payment_method" value="<?php echo JRequest::getVar('payment_method', '0'); ?>" />
			<input type="hidden"  name="Itemid" value="<?php echo JRequest::getInt('Itemid', 0);?>" />	
		</form>
</div>
</div>